package com.yamaha.bikedesalon.util;

import android.app.Activity;
import android.app.AlertDialog;
import android.os.Handler;

public final class ProgressHUD {

	private final static int delay = 500;

	public static void showSuccess(final Activity activity, final String message) {
		final AlertDialog.Builder builder = new AlertDialog.Builder(activity);
		builder.setCancelable(true);
		builder.setMessage(message);
		final AlertDialog dialog = builder.create();
		dialog.show();

		final Handler handler = new Handler();
		handler.postDelayed(new Runnable() {

			@Override
			public void run() {
				dialog.cancel();
				dialog.dismiss();
			}
		}, delay);
	}

	public static void showFailure(final Activity activity, final String message) {
		final AlertDialog.Builder builder = new AlertDialog.Builder(activity);
		builder.setCancelable(true);
		builder.setMessage(message);
		final AlertDialog dialog = builder.create();
		dialog.show();

		final Handler handler = new Handler();
		handler.postDelayed(new Runnable() {

			@Override
			public void run() {
				dialog.cancel();
				dialog.dismiss();
			}
		}, delay);
	}
}
